<script setup lang="ts">
import { reactive, ref, watch, computed, onMounted } from 'vue'

const themeList = reactive(
    [
        {
            id: 1,
            name: '黑暗',
            color: '#1e1e1e'
        },
        {
            id: 2,
            name: '黑暗',
            color: '#f4bf50'
        }, {
            id: 3,
            name: '黑暗',
            color: '#4acac9'
        }, {
            id: 4,
            name: '黑暗',
            color: '#f2b9b9'
        }
    ]
)

const theme = (type: any) => {
    // window.document.documentElement.setAttribute('data-theme', type)
}
</script>

<template>
    <div class="affix">
        <div class="back">
            <el-icon :size="20" color="#fff" class="tool">
                <Tools />
            </el-icon>
        </div>
        <div class="theme">
            <div class="box" v-for="item in themeList" :key="item.id" :style="{ 'background-color': item.color }"
                @click.native="theme('Red')"></div>
        </div>
    </div>
    <el-backtop :visibility-height="0">
        <el-icon color="#ffffff">
            <Top />
        </el-icon>
    </el-backtop>
</template>
    
<style scoped lang="scss">
.affix {
    position: fixed;
    right: 2vw;
    top: 40%;
    width: 50px;
    height: 200px;
    border-radius: 10px;
    box-shadow: $box-shadow;
    overflow: hidden;

    .back {
        background-color: $theme-color;
        height: 50px;
        @include flex();

        .tool:hover {
            cursor: pointer;
            animation: rotate 1s;
        }
    }

    .theme {
        @include flex-column();

        .box {
            margin-top: 5px;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            cursor: pointer;
            border: 5px solid $bgcolor;
            box-shadow: $box-shadow;
            transition-duration: 0.1s;
            transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
        }

        .box:hover {
            transform: scale(1.2);
        }

    }
}

.el-backtop{
    background-color: $theme-color;
}

@keyframes rotate {
    from {
        transform: rotate(0);
    }

    to {
        transform: rotate(180deg);
    }
}
</style>